package com.finalab.yueqiu.dao.auth;


import com.finalab.yueqiu.dao.auth.po.UserAuthPO;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @author 莉安
 */
@Mapper
public interface UserAuthDAO {
     String TABLE_NAME = "e_user_auth";
     String INSERT_FIELD = "phone, user_phone";
     String SELECT_FIELD = "id, phone, email, user_phone userPhone, id_card idCard";

    @Insert({"insert into ",TABLE_NAME,"(", INSERT_FIELD, ") values( #{phone}, #{userPhone} )"})
    void insert(@Param("phone")int phone, @Param("userPhone")String userPhone);

    @Select({"select ",SELECT_FIELD," from ",TABLE_NAME," where id = #{id}"})
    UserAuthPO selectById(@Param("id") int id);

    @Update({"update ",TABLE_NAME," set email = #{email} where id = #{id}"})
    void updateEmail(@Param("email")int email);

    @Select({"select ",SELECT_FIELD," from ",TABLE_NAME," where user_phone = #{userPhone}"})
    UserAuthPO selectByPhone(@Param("userPhone") String userPhone);

    @Select({"select id from ", TABLE_NAME, " where exists(select * from ", TABLE_NAME,
            " where id = #{id})"})
    List<Object> exists(@Param("id")int id);



}
